package com.web;

import com.alibaba.fastjson.JSONArray;
import com.bean.Subsidy;
import com.service.ISubsidyManagementService;
import com.service.SubsidyManagementServiceImp;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/SubsidyReviseServlet")
public class SubsidyReviseServlet extends HttpServlet
{
    private ISubsidyManagementService subsidyManagementService = new SubsidyManagementServiceImp();
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req, resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException
    {
        //获取参数列表
        Subsidy subsidy = new Subsidy(
                Integer.parseInt(req.getParameter("subsidy_id")),
                req.getParameter("subsidy_project_name"),
                Integer.parseInt(req.getParameter("subsidy_subject_id")),
                Integer.parseInt(req.getParameter("countryside_department_id")),
                Integer.parseInt(req.getParameter("city_department_id")),
                0
        );

        //判断是否有最后一个参数来判断是否有启用标记
        if(req.getParameter("flag")!=null)
            subsidy.setFlag(true);

        System.out.println(subsidy);

        boolean result = subsidyManagementService.reviseSubsidy(subsidy);
    }
}
